package com.nuc.bigdata.feign;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.nuc.bigdata.domain.entity.User;
import com.nuc.bigdata.exception.BusinessException;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 调用oa-user服务的feign客户端
 * @author JackLuo
 * @date 2019/10/31
 */
@FeignClient(name = "oa-user")
public interface UserServiceFeign {

    /**
     * 调用oa-user服务中注册用户功能
     * @param user 前端用户
     * @return 数据库新插入用户数据
     * @throws Exception 抛出异常
     */
    @PostMapping("/oa-user/user")
    @HystrixCommand(ignoreExceptions = BusinessException.class)
    User signUp(@RequestBody User user) throws Exception;

    /**
     * 调用oa-user服务中登录用户功能
     * @param loginName 登录用户名
     * @param password 密码
     * @return 用户信息
     * @throws Exception 异常
     */
    @GetMapping("/oa-user/user")
    @HystrixCommand(ignoreExceptions = BusinessException.class)
    User toLogin(@RequestParam("loginName") String loginName, @RequestParam("password") String password) throws Exception;


    /**
     * 根据用户唯一标识查询用户信息feign
     * @param userId 用户唯一标识
     * @return 用户信息feign
     */
    @GetMapping("/oa-user/{userId}")
    User queryByUserId(@PathVariable("userId")String userId);
}
